from flask import Flask
from flask import render_template
import threading

import motor

app = Flask(__name__)



sharedMotorManager = None

@app.route('/')
def hello(name=None):
    return "Hello there!"

@app.route('/start')
def start():
    sharedMotorManager = threading.Thread(target = motor.rotateMotor(1))
    sharedMotorManager.start()
    return "Starting!"

@app.route('/stop')
def stop():
    if sharedMotorManager:
        sharedMotorManager.stop()
        motor.stopRotating()
    return "Stopped!"


@app.route('/test')
def stop():
    motor.stopRotating()
    return "Teset!"


if __name__ == "__main__":
    app.run('0.0.0.0', threaded=true, debug=True)
